﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PlayerUIController : MonoBehaviour
{

    public Slider stamina;
    public GameObject skillUI;
    PlayerStatus playerStatus;

    // Start is called before the first frame update
    void Start()
    {
        playerStatus = GetComponent<PlayerStatus>();
    }

    // Update is called once per frame
    void Update()
    {
        if (stamina != null){
            float value = (playerStatus.stamina.num - playerStatus.stamina.min) / (playerStatus.stamina.max - playerStatus.stamina.min);
            stamina.gameObject.SetActive((value < 1));
            stamina.value = value;
        }
        GameObject mask = skillUI.transform.Find("Mask").gameObject;
        skillUI.gameObject.SetActive(GetComponent<SkillBase>().getRemainCooldown() > 0);
        mask.GetComponent<Image>().fillAmount = GetComponent<SkillBase>().getRemainCooldown() /GetComponent<SkillBase>().cooldown;



    }
}
